package com.wanmait.recycle.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.github.pagehelper.PageInfo;
import com.wanmait.recycle.pojo.Article;
import com.wanmait.recycle.pojo.Comment;
import com.wanmait.recycle.pojo.Userinfo;
import com.wanmait.recycle.service.ArticleService;
import com.wanmait.recycle.util.IPUtil;

@Controller
@RequestMapping("/manager/article")
public class ArticleController {

	@Resource
	private ArticleService articleService;
	
	@RequestMapping("articleList")
	@ModelAttribute("articles")
	public List<Article> article() {
		
		return articleService.findAll();
	}
	
	//新闻上线
	@RequestMapping("update")
	@ResponseBody
	public void update(Integer id) {
		articleService.shangXian(id);
	}
	
	
	//新闻下线
	@RequestMapping("below")
	@ResponseBody
	public void below(Integer id) {
		articleService.xiaXian(id);
	}
	
	//新闻上线
	@RequestMapping("updateMO")
	@ResponseBody
	public void update1(String ids) {
		articleService.shangXianshangXianByIds(ids);
	}
	
	
	//新闻下线
	@RequestMapping("belowMO")
	@ResponseBody
	public void below1(String ids) {
		articleService.xiaXianByIds(ids);
	}
	
	@RequestMapping("articleSingle")
	public ModelAndView article(Integer articleId,HttpSession session,HttpServletRequest request) {
		ModelAndView mv = new ModelAndView();
		Article article = articleService.findByArticleId2(articleId);
	
		mv.addObject("article", article);
	
		
		
		return mv;
		
	}
	
}
